﻿using System;
using System.Collections.Generic;
using System.Text;
using Engine.MathEx;
using Engine;
using GameEntities;
using Engine.EntitySystem;
using Game;

namespace Arcanea.MMORPGClient
{
    class MMORPGStoryGameWindow : MMORPGGameWindow
    {
        protected override void OnTick(float delta)
        {
            base.OnTick(delta);

            //This lauches a Tick event on all entities
            EntitySystemWorld.Instance.Tick(false);
        }

        protected override void OnRender()
        {
            base.OnRender();
            //TODO: Specific render logic goes here
        }

        protected override void OnGetCameraTransform(out Vec3 position, out Vec3 forward, out Vec3 up, ref Degree cameraFov)
        {
            //get the default spawn point
            SpawnPoint spawnPoint = SpawnPoint.GetDefaultSpawnPoint();

            //place the camara above the spawn point
            position = spawnPoint.Position + new Vec3(0, 0, 10);

            //look at some point above the paddle (around the center of the game board)
            Vec3 lookAt = spawnPoint.Position + new Vec3(5, 0, 0);

            //the forward direction of the camera is
            forward = (lookAt - position).GetNormalize();

            //the up vector, is the one perpendicular to XAxis and forward.
            up = Vec3.Cross(forward, Vec3.YAxis);

            //use a fov of 80 degrees
            cameraFov = new Degree(80);
        }

        protected override bool OnKeyDown(KeyEvent e)
        {
            //To pass the command in Controllers system
            if (GameControlsManager.Instance.DoKeyDown(e))
                return true;

            return base.OnKeyDown(e);
        }

        protected override bool OnKeyUp(KeyEvent e)
        {
            //To pass the command in Controllers system
            if (GameControlsManager.Instance.DoKeyUp(e))
                return true;

            return base.OnKeyUp(e);
        }

    }
}
